from funcGame import *

def Player(game, team):
	return {"game": game, "team": team}

def AIPlayer(game, team):
	dict = Player(game, team)
	
	def play():
		# TO DO: DEIXAR ISSO FUNCIONAL, FIZ SOH PRA TESTAR
		for i in range(Game.boardWidth):
			for j in range(Game.boardHeight):
				if game[i,j].upper() == game.turn and game.turn == team:
					game.generateMoves((i,j))
					if len(game.validMoves) > 0:
						game.move((i,j), game.validMoves[0])
						return
	
	dict['play'] = play
	return dict
	
def HumanPlayer(game, team):
	dict = Player(game, team)
	
	def mouseClick(pieceSelected, pos):
		if game[pos[0],pos[1]].upper() == game.turn and game.turn == team:
			game.generateMoves(pos)
			return pos
		elif pieceSelected != None and game.turn == team:
			game.move(pieceSelected, pos)
			return None
		else:
			return None
	
	dict["mouseClick"] = mouseClick
	return dict